package ute.mvc.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Transient;

import ute.mvc.dto.QuestionDTO;

import com.fasterxml.jackson.annotation.JsonIgnore;

@Entity
public class TestPart implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2712375826224746625L;
	@Id
	@Column(length = 50)
	private String testPartId;
	@Column(length = 100, nullable = false)
	private String testPartName;
	@Column(name = "pointForPool")
	private double point;
	@Column(name = "numberQuestion")
	private int numberQuestion;

	@JsonIgnore
	@ManyToOne
	@JoinColumn(name = "testAndAuizzId", nullable = false)
	private TestAndQuizz testAndQuizz;

	@JsonIgnore
	@OneToOne
	@JoinColumn(name = "questionPoolId")
	private QuestionPool questionPool;

	@JsonIgnore
	@OneToMany(mappedBy = "testPart", fetch = FetchType.EAGER)
	private Collection<Question> listQuestion = new ArrayList<Question>();
	
	@JsonIgnore
	@Transient
	private Collection<QuestionDTO> listQuestionDTO = new ArrayList<QuestionDTO>();

	public Collection<QuestionDTO> getListQuestionDTO() {
		return listQuestionDTO;
	}

	public void setListQuestionDTO(Collection<QuestionDTO> listQuestionDTO) {
		this.listQuestionDTO = listQuestionDTO;
	}

	public Collection<Question> getListQuestion() {
		return listQuestion;
	}

	public void setListQuestion(Collection<Question> listQuestion) {
		this.listQuestion = listQuestion;
	}

	public double getPoint() {
		return point;
	}

	public void setPoint(double point) {
		this.point = point;
	}

	public int getNumberQuestion() {
		return numberQuestion;
	}

	public void setNumberQuestion(int numberQuestion) {
		this.numberQuestion = numberQuestion;
	}

	public TestAndQuizz getTestAndQuizz() {
		return testAndQuizz;
	}

	public void setTestAndQuizz(TestAndQuizz testAndQuizz) {
		this.testAndQuizz = testAndQuizz;
	}

	public QuestionPool getQuestionPool() {
		return questionPool;
	}

	public void setQuestionPool(QuestionPool questionPool) {
		this.questionPool = questionPool;
	}

	public String getTestPartId() {
		return testPartId;
	}

	public void setTestPartId(String testPartId) {
		this.testPartId = testPartId;
	}

	public String getTestPartName() {
		return testPartName;
	}

	public void setTestPartName(String testPartName) {
		this.testPartName = testPartName;
	}
}